package com.zyf.pattern.observer.mouse;

import com.zyf.pattern.observer.core.Event;
import com.zyf.pattern.template.entity.Member;

import java.lang.reflect.Method;

/**
 * create by yifeng
 */
public class MouseTest {
    public static void main(String[] args) {


        // 观察者和被观察者之间没有必然的联系
        // 注册的时候才产生联系

        // 解耦

        try {
            MouseEventCallback callback = new MouseEventCallback();
            Method onClick = MouseEventCallback.class.getMethod("onClick", Event.class);
            Method onDoubleClick = MouseEventCallback.class.getMethod("onDoubleClick", Event.class);
            // 人为调用鼠标的单击事件
            Mouse mouse = new Mouse();
            // 注册对应的监听事件
            mouse.addLisenter(MouseEventType.ON_CLICK, callback, onClick);
//            mouse.addLisenter(MouseEventType.ON_DOUBLE_CLICK, callback, onDoubleClick);
            mouse.doubleClick();
            mouse.click();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }


    }

}
